package com.gaohe.web.controller.hotal;

import com.gaohe.common.annotation.Log;
import com.gaohe.common.core.controller.BaseController;
import com.gaohe.common.core.domain.AjaxResult;
import com.gaohe.common.core.page.TableDataInfo;
import com.gaohe.common.enums.BusinessType;
import com.gaohe.common.utils.poi.ExcelUtil;
import com.gaohe.hotal.domain.HotRoomType;
import com.gaohe.hotal.service.IHotRoomTypeService;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 房间类型Controller
 *
 * @author ruoyi
 * @date 2025-07-02
 */
@RestController
@RequestMapping("/hotal/type")
public class HotRoomTypeController extends BaseController
{
    @Autowired
    private IHotRoomTypeService hotRoomTypeService;

    /**
     * 查询房间类型列表
     */
    @PreAuthorize("@ss.hasPermi('hotal:type:list')")
    @GetMapping("/list")
    public TableDataInfo list(HotRoomType hotRoomType)
    {
        startPage();
        List<HotRoomType> list = hotRoomTypeService.selectHotRoomTypeList(hotRoomType);
        return getDataTable(list);
    }

    /**
     * 导出房间类型列表
     */
    @PreAuthorize("@ss.hasPermi('hotal:type:export')")
    @Log(title = "房间类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HotRoomType hotRoomType)
    {
        List<HotRoomType> list = hotRoomTypeService.selectHotRoomTypeList(hotRoomType);
        ExcelUtil<HotRoomType> util = new ExcelUtil<HotRoomType>(HotRoomType.class);
        util.exportExcel(response, list, "房间类型数据");
    }

    /**
     * 获取房间类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('hotal:type:query')")
    @GetMapping(value = "/{roomTypeId}")
    public AjaxResult getInfo(@PathVariable("roomTypeId") Long roomTypeId)
    {
        return success(hotRoomTypeService.selectHotRoomTypeByRoomTypeId(roomTypeId));
    }

    /**
     * 新增房间类型
     */
    @PreAuthorize("@ss.hasPermi('hotal:type:add')")
    @Log(title = "房间类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HotRoomType hotRoomType)
    {
        return toAjax(hotRoomTypeService.insertHotRoomType(hotRoomType));
    }

    /**
     * 修改房间类型
     */
    @PreAuthorize("@ss.hasPermi('hotal:type:edit')")
    @Log(title = "房间类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HotRoomType hotRoomType)
    {
        return toAjax(hotRoomTypeService.updateHotRoomType(hotRoomType));
    }

    /**
     * 删除房间类型
     */
    @PreAuthorize("@ss.hasPermi('hotal:type:remove')")
    @Log(title = "房间类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{roomTypeIds}")
    public AjaxResult remove(@PathVariable Long[] roomTypeIds)
    {
        return toAjax(hotRoomTypeService.deleteHotRoomTypeByRoomTypeIds(roomTypeIds));
    }
}
